const koa = require("koa");
const Router = require("@koa/router")
const parameter = require('koa-parameter');
const error = require('koa-json-error')
const app = new koa();
const router = new Router({
    prefix:"/hello"
});



router.get('/', (ctx,next) => {
    ctx.verifyParams({ //检验的是body中的数据的类型
        name: {
            type:'string',
            required:false
        },
        password:{
            type:'string',
            required:true
        }
    });

    ctx.body="---"
});


let options = {
    postFormat: (e, obj) => {
        return  process.env.NODE_ENV === 'pro' ? _.omit(obj, 'stack') : obj
    }
}
parameter(app);
app.use(error(options))
app.use(router.routes());
app.listen(8888,"127.0.0.1",()=>{
    console.log("server is running on http://127.0.0.1:8888")
})